package com.beiben.project.domain;

import com.beiben.work.process.domain.FileProcessUser;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 项目管理对象 pm_project
 *
 * @author 熊国强
 * @date 2020-12-03
 */
public class Project extends BaseEntity {

    private static final long serialVersionUID = 1L;

    /**
     * 项目主键
     */
    private Long projectId;

    /**
     * 父ID
     */
    private Long parentId;

    /**
     * 祖级列表
     */
    private String ancestors;

    /*
    * 序号
    * */
    private String serial;

    /**
     * 项目名称
     */
    @Excel(name = "项目名称")
    private String projectName;

    /**
     * 项目令号
     */
    @Excel(name = "项目令号")
    private String projectCode;

    /**
     * 年限
     */
    @Excel(name = "年限", width = 30, dateFormat = "yyyy")
    private String projectTime;

    /**
     * 项目类型
     */
    @Excel(name = "项目类型")
    private String projectType;

    /**
     * 开始时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "开始时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date startTime;

    /**
     * 结束时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "结束时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date finishTime;

    /**
     * 实际完成时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "实际完成时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date relFinishTime;

    /**
     * 是否超时
     */
    @Excel(name = "是否超时")
    private String isTimeOut;

    /**
     * 是否为里程碑节点
     */
    @Excel(name = "是否为里程碑节点")
    private String isImportant;

    /**
     * 责任部门
     */
    @Excel(name = "责任部门")
    private Long deptId;

    /**
     * 责任人
     */
    @Excel(name = "项目经理")
    private Long userId;

    /**
     * 责任人
     */
    @Excel(name = "项目总师")
    private Long technologyLeaderUserId;

    /**
     * 状态
     */
    @Excel(name = "状态")
    private Integer state;

    private String deptName;//组织机构

    private String nickName;// 责任人名称

    private String technologyLeader;//总师

    private String relParentId;//传递过来的父ID


    /**
     * 每日工作时长
     */
    @Excel(name = "每日工作时长")
    private BigDecimal workHours;

    /**
     * 文件时长
     */
    @Excel(name = "文件时长")
    private Double fileHours;

    /**
     * 文件时长ID
     */
    @Excel(name = "文件时长ID")
    private Long fileId;

    /**
     * 审核人ID
     */
    private Long checkUserId;

    /**
     * 审核人
     */
    private String checkUserName;

    /*
    * 责任人
    * */
    private String userName;

    /**
     * 项目经理id
     */
    private Long projectManagerId;

    /*
    * 是否包含子节点
    * */
    private boolean hasChildren;

    /*
    * 是否是工作(0:节点，1：工作)
    * */
    private int isWork;
    /**
     * 子部门
     */
    private List<Project> children = new ArrayList<Project>();

    public BigDecimal getWorkHours() {
        return workHours;
    }

    public void setWorkHours(BigDecimal workHours) {
        this.workHours = workHours;
    }

    public Double getFileHours() {
        return fileHours;
    }

    public void setFileHours(Double fileHours) {
        this.fileHours = fileHours;
    }

    public Long getFileId() {
        return fileId;
    }

    public void setFileId(Long fileId) {
        this.fileId = fileId;
    }

    public Long getCheckUserId() {
        return checkUserId;
    }

    public void setCheckUserId(Long checkUserId) {
        this.checkUserId = checkUserId;
    }

    public String getCheckUserName() {
        return checkUserName;
    }

    public void setCheckUserName(String checkUserName) {
        this.checkUserName = checkUserName;
    }

    public void setProjectId(Long projectId) {
        this.projectId = projectId;
    }

    public Long getProjectId() {
        return projectId;
    }

    public void setParentId(Long parentId) {
        this.parentId = parentId;
    }

    public Long getParentId() {
        return parentId;
    }

    public void setAncestors(String ancestors) {
        this.ancestors = ancestors;
    }

    public String getAncestors() {
        return ancestors;
    }

    public void setProjectName(String projectName) {
        this.projectName = projectName;
    }

    public String getProjectName() {
        return projectName;
    }

    public void setProjectCode(String projectCode) {
        this.projectCode = projectCode;
    }

    public String getProjectCode() {
        return projectCode;
    }

    public void setProjectTime(String projectTime) {
        this.projectTime = projectTime;
    }

    public String getProjectTime() {
        return projectTime;
    }

    public void setProjectType(String projectType) {
        this.projectType = projectType;
    }

    public String getProjectType() {
        return projectType;
    }

    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    public Date getStartTime() {
        return startTime;
    }

    public void setFinishTime(Date finishTime) {
        this.finishTime = finishTime;
    }

    public Date getFinishTime() {
        return finishTime;
    }

    public void setRelFinishTime(Date relFinishTime) {
        this.relFinishTime = relFinishTime;
    }

    public Date getRelFinishTime() {
        return relFinishTime;
    }

    public void setIsTimeOut(String isTimeOut) {
        this.isTimeOut = isTimeOut;
    }

    public String getIsTimeOut() {
        return isTimeOut;
    }

    public void setIsImportant(String isImportant) {
        this.isImportant = isImportant;
    }

    public String getIsImportant() {
        return isImportant;
    }

    public void setDeptId(Long deptId) {
        this.deptId = deptId;
    }

    public Long getDeptId() {
        return deptId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public Long getUserId() {
        return userId;
    }

    public String getDeptName() {
        return deptName;
    }

    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }

    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    public String getRelParentId() {
        return relParentId;
    }

    public void setRelParentId(String relParentId) {
        this.relParentId = relParentId;
    }

    public List<Project> getChildren() {
        return children;
    }

    public void setChildren(List<Project> children) {
        this.children = children;
    }

    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    public Long getTechnologyLeaderUserId() {
        return technologyLeaderUserId;
    }

    public void setTechnologyLeaderUserId(Long technologyLeaderUserId) {
        this.technologyLeaderUserId = technologyLeaderUserId;
    }

    public Long getProjectManagerId() {
        return projectManagerId;
    }

    public void setProjectManagerId(Long projectManagerId) {
        this.projectManagerId = projectManagerId;
    }

    public String getTechnologyLeader() {
        return technologyLeader;
    }

    public void setTechnologyLeader(String technologyLeader) {
        this.technologyLeader = technologyLeader;
    }

    public boolean isHasChildren() {
        return hasChildren;
    }

    public void setHasChildren(boolean hasChildren) {
        this.hasChildren = hasChildren;
    }

    public int getIsWork() {
        return isWork;
    }

    public void setIsWork(int isWork) {
        this.isWork = isWork;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getSerial() {
        return serial;
    }

    public void setSerial(String serial) {
        this.serial = serial;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                .append("projectId", getProjectId())
                .append("parentId", getParentId())
                .append("ancestors", getAncestors())
                .append("projectName", getProjectName())
                .append("projectCode", getProjectCode())
                .append("projectTime", getProjectTime())
                .append("projectType", getProjectType())
                .append("startTime", getStartTime())
                .append("finishTime", getFinishTime())
                .append("relFinishTime", getRelFinishTime())
                .append("isTimeOut", getIsTimeOut())
                .append("isImportant", getIsImportant())
                .append("deptId", getDeptId())
                .append("userId", getUserId())
                .append("createTime", getCreateTime())
                .append("updateTime", getUpdateTime())
                .append("createBy", getCreateBy())
                .append("updateBy", getUpdateBy())
                .toString();
    }

    public FileProcessUser conversionToFileProcessUser() {
        FileProcessUser fileProcessUser = new FileProcessUser();
        fileProcessUser.setWorkId(this.getProjectId());
        fileProcessUser.setUserId(this.getUserId());
        fileProcessUser.setState(0);
        fileProcessUser.setStartTime(this.getStartTime());
        fileProcessUser.setFinishTime(this.getFinishTime());
        fileProcessUser.setWorkType("2");
        fileProcessUser.setCheckUserId(this.getCheckUserId());
        fileProcessUser.setWorkContent(this.getProjectName());
        fileProcessUser.setParentId(this.getParentId());
        fileProcessUser.setFileId(this.getFileId());
        fileProcessUser.setFileHours(this.getFileHours() == null ? 0 : this.getFileHours());
        fileProcessUser.setWorkHours(this.getWorkHours() == null ? new BigDecimal(0) : this.getWorkHours());
        return fileProcessUser;
    }
}
